<template>
	<uni-swiper-dot :info="info" :current="current" field="content" :mode="mode" @change="change">
		<swiper class="swiper-box" autoplay="true" interval="3000" :current="current" @change="swiperChange">
			<swiper-item v-for="(item ,index) in info" :key="index">
				 <a :href="item.links" target="_blank">
					<view class="swiper-item">
						<img :src="item.picture" style="width: 100%;height: 150px;"></img>
					</view>
				</a>
			</swiper-item>
		</swiper>
	</uni-swiper-dot>

</template>

<script>
	// 引入 request 文件
	import request from '@/util/request';
	export default {
		data() {
			return {
				info: [{
					picture: '内容 A'
				}, {
					picture: '内容 B'
				}, {
					picture: '内容 C'
				}],
				current: 0,
				mode: 'round',
			}
		},
		//进入页面加载方法
		mounted() {
			console.log("onShow111");
			this.advertisement();
		},
		methods: {
			change(e) {
				this.current = e.detail.current;
			},
			swiperChange(e) {
				this.current = e.detail.current;
			},
			//请求广告列表
			advertisement() {
				//异步发送请求
				// const res = await uni.request({
				// 	url: 'http://localhost:8080/home/advertisement/lselect',
				// 	//data:params  //请求参数
				// })
				const res = request({
					url: '/home/advertisement/lselect',
					method: 'get',
				})
				res.then(res => {
					console.log(res)
					this.info = res.data;
				}).catch(err => {
					console.log("xxxx");
				})
			},
		}
	}
</script>

<style>
</style>